/**
 * @author Jialun Bian
 * @version 1.0
 */
package userInterface;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.net.URL;
public class MainToolBar extends JPanel implements ActionListener {
    static final private String ACTION_NEW = "new";
    static final private String ACTION_SETTINGS = "settings";
    static final private String ACTION_OPEN = "open";
    static final private String ACTION_SAVE = "save";
    static final private String ACTION_EXPORT = "export";
    static final private String ACTION_QUIT = "quit";
    public MainToolBar() {
        super(new BorderLayout());

        JToolBar toolBar=new JToolBar("MainToolBar");
        addButtons(toolBar);
        toolBar.setFloatable(false);
        
        setPreferredSize(new Dimension(400,130));
        add(toolBar,BorderLayout.PAGE_START);
    }

    protected void addButtons(JToolBar toolBar) {
        JButton button=null;
        button = makeNavigationButton("images/new.gif",ACTION_NEW,"New a file","New");
        toolBar.add(button);
        button = makeNavigationButton("images/save.gif",ACTION_SAVE,"Save the Panel","Save");
        toolBar.add(button);
        button = makeNavigationButton("images/open.gif",ACTION_OPEN,"Open the LOG file","Open");
        toolBar.add(button);
        button = makeNavigationButton("images/export.gif",ACTION_EXPORT,"Export the Panel","Export");
        toolBar.add(button);
        button = makeNavigationButton("images/settings.gif",ACTION_SETTINGS,"Settings","Settings");
        toolBar.add(button);
        button = makeNavigationButton("images/quit.gif",ACTION_QUIT,"Quit","Quit");
        toolBar.add(button);
    }
    protected JButton makeNavigationButton(String imgLocation,
            String actionCommand,
            String toolTipText,
            String altText) {
        //Look for the image.

        //Create and initialize the button.
        JButton button = new JButton();
        button.setActionCommand(actionCommand);
        button.setToolTipText(toolTipText);
        button.addActionListener(this);

        button.setMaximumSize(new Dimension(60,60));
        //button.setMinimumSize(new Dimension(40,40));
        

        button.setIcon(new ImageIcon(imgLocation));

        return button;
    }
    public void actionPerformed(ActionEvent e) {
        String cmd = e.getActionCommand();
        //inplement the cmd
    }


}
